<?php

/**
 * This is the model class for table "mall_order_child".
 *
 * The followings are the available columns in table 'mall_order_child':
 * @property string $order_id
 * @property string $order_num
 * @property string $parent_id
 * @property string $user_id
 * @property string $goods_id
 * @property string $goods_name
 * @property string $goods_pic
 * @property string $shop_id
 * @property string $shop_name
 * @property string $detail_info
 * @property string $num
 * @property double $price
 * @property double $discount
 * @property double $totalprice
 * @property string $create_time
 * @property string $update_time
 * @property string $created_by
 * @property string $updated_by
 * @property integer $is_delete
 */
class MallOrderChild extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return MallOrderChild the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'mall_order_child';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('order_num, user_id, goods_id, goods_name, goods_pic, shop_id, shop_name, num, price', 'required'),
			array('is_delete', 'numerical', 'integerOnly'=>true),
			array('price, discount, totalprice', 'numerical'),
			array('order_num, shop_name, created_by, updated_by', 'length', 'max'=>255),
			array('parent_id', 'length', 'max'=>60),
			array('user_id, shop_id', 'length', 'max'=>20),
			array('goods_id', 'length', 'max'=>64),
			array('goods_name', 'length', 'max'=>1024),
			array('num', 'length', 'max'=>10),
			array('detail_info, create_time, update_time', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('order_id, order_num, parent_id, user_id, goods_id, goods_name, goods_pic, shop_id, shop_name, detail_info, num, price, discount, totalprice, create_time, update_time, created_by, updated_by, is_delete', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'order_id' => 'Order',
			'order_num' => 'Order Num',
			'parent_id' => 'Parent',
			'user_id' => 'User',
			'goods_id' => 'Goods',
			'goods_name' => 'Goods Name',
			'goods_pic' => 'Goods Pic',
			'shop_id' => 'Shop',
			'shop_name' => 'Shop Name',
			'detail_info' => 'Detail Info',
			'num' => 'Num',
			'price' => 'Price',
			'discount' => 'Discount',
			'totalprice' => 'Totalprice',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
			'created_by' => 'Created By',
			'updated_by' => 'Updated By',
			'is_delete' => 'Is Delete',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('order_id',$this->order_id,true);
		$criteria->compare('order_num',$this->order_num,true);
		$criteria->compare('parent_id',$this->parent_id,true);
		$criteria->compare('user_id',$this->user_id,true);
		$criteria->compare('goods_id',$this->goods_id,true);
		$criteria->compare('goods_name',$this->goods_name,true);
		$criteria->compare('goods_pic',$this->goods_pic,true);
		$criteria->compare('shop_id',$this->shop_id,true);
		$criteria->compare('shop_name',$this->shop_name,true);
		$criteria->compare('detail_info',$this->detail_info,true);
		$criteria->compare('num',$this->num,true);
		$criteria->compare('price',$this->price);
		$criteria->compare('discount',$this->discount);
		$criteria->compare('totalprice',$this->totalprice);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('created_by',$this->created_by,true);
		$criteria->compare('updated_by',$this->updated_by,true);
		$criteria->compare('is_delete',$this->is_delete);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}